import React, {Component} from 'react';

class Reg extends Component {
    state = {
        userName:"lisi",
        passWord:"if(1===1){console.log('iloveyou')}",
        rePassWord:"if(1===1){console.log('iloveyou')}",
    }
    changeHandler(e){
        this.setState({
            [e.target.name]:e.target.value
        })
    }
    submitHandler(e){
        e.preventDefault();
        console.log(this.state.userName);
        console.log(this.state.passWord);
        console.log(this.state.rePassWord);
    }
    render() {
        return (
            <div>
                <h3>注册</h3>
                <form onSubmit={this.submitHandler.bind(this)}>
                    <p>用户名：<input onChange={this.changeHandler.bind(this)} name={"userName"}  value={this.state.userName} type="text"/></p>
                    <p>密码：<input  onChange={this.changeHandler.bind(this)} name={"passWord"} value={this.state.passWord} type="password"/></p>
                    <p>重复密码：<input  onChange={this.changeHandler.bind(this)} name={"rePassWord"} value={this.state.rePassWord} type="password"/></p>
                    <button>提交</button>
                </form>
            </div>
        );
    }
}

export default Reg;